﻿<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Agenda Posgrad - Relatórios</title>
<%@ include file="../../includes/head.jsp" %>
	
	<script type="text/javascript">
		$(function() {
			$("#abas").tabs().find(".ui-tabs-nav").sortable({axis:'x'});
		});
	</script>
		
	<script type="text/javascript">
		var proposta_id = 0;
	
		$(function() {
			$("#dialog").dialog({
				autoOpen: false,
				modal: true,
				buttons: {
					"Fechar": function() {$("#resultado",this).text('');$(this).dialog('close');}
				}
			});

			$("#dialog-detalhes").dialog({
				autoOpen: false,
				modal: true,
				beforeclose: function(event, ui) {
					$('#content',this).text("");
					proposta_id = 0;
				},
				buttons: {
					"Visualizar Proposta": function() {window.open("admin/propostas/pdf/"+proposta_id,"","width=250,height=300,status=yes,toolbar=no,menubar=no");}
				}
			});			
			
			$(".btn-detalhes").click(function (event) {
				var loader = $('#loader');
				var dialog = $('#dialog-detalhes');
				var content	= $('#dialog-detalhes #content');			
				var title = "Detalhes da Proposta de " + $(this).attr("alt");

				loader.show();
				event.preventDefault();
				dialog.dialog("option" , "title" , title);
				dialog.dialog('open');
				content.load($(this).attr("href"), function() {
					$('#loader').hide();					
					proposta_id = $("#proposta_id").val();
				});
			});
		});

		$(document).ajaxError(function(event, xhr, settings, exception) {
			var errorMsg = "Erro ao acessar url '" + settings.url + "'("+ settings.type +"):\n"+xhr.status+" - "+xhr.statusText+" \nExceçao:"+exception;    			
			$('#dialog').text(errorMsg).dialog('open');
		});		
	</script>
</head>
<body>
<%@ include file="../includes/topo.jsp" %>

<div id="nome_acao">Relatórios</div>
			<div id="abas">
				<ul>
					<li><a href="#aba-1">Propostas</a></li>
					<li><a href="#aba-2">Defesas</a></li>
				</ul>
				<div id="aba-1">
					<c:choose>
					<c:when test="${empty pendenciasProposta}">
						<p>Nenhuma proposta homologada.</p>
					</c:when>
					<c:otherwise>	
				        <table width="100%" bordercolor="#000000" border="0" cellspacing="3" cellpadding="2">
				              <tr>
				                <th>Nº Processo</th>
				                <th>Data defesa</th>
				                <th>Nome do Orientador</th>
				                <th>Nome do Aluno</th>
				                <th>Opções</th>
				              </tr>
				              <c:forEach items="${pendenciasProposta}" var="proposta" varStatus="c">
				              <tr>
				                <td align="center" bgcolor="#A7D7ED"><fmt:formatNumber value="${proposta.id}" minIntegerDigits="4" groupingUsed=""/></td>
				                <td align="center" bgcolor="#A7D7ED"><fmt:formatDate value="${proposta.data_proposta}" pattern="dd/MM/yyyy"/></td>
				                <td align="center" bgcolor="#A7D7ED">${proposta.orientador.nome}</td>
				                <td align="center" bgcolor="#A7D7ED">${proposta.aluno.nome}</td>
				                <td align="center" bgcolor="#A7D7ED">
				                	<!--<a href="admin/propostas/${proposta.id}" class="btn btn-detalhes" id="${proposta.id}">Detalhes</a>-->
				                	<a href="admin/relatorios/propostas/declaracao-proposta-${proposta.id}" class="btn">Declaração</a>
				                	<a href="admin/relatorios/propostas/ata-proposta-${proposta.id}" class="btn">Ata Proposta</a>
				                </td>
				              </tr>
				              </c:forEach>
				            </table>
				         </c:otherwise>
				       </c:choose>
		         </div>
		         <div id="aba-2">
			         <c:choose>
						<c:when test="${empty pendenciasDefesa}">
							<p>Nenhuma defesa homologada.</p>
						</c:when>
						<c:otherwise>
							<table width="100%" bordercolor="#000000" border="0" cellspacing="3" cellpadding="2">
				              <tr>
				                <th>Nº Processo</th>
				                <th>Data defesa</th>
				                <th>Nome do Orientador</th>
				                <th>Nome do Aluno</th>
				                <th>Opções</th>
				              </tr>
				              <c:forEach items="${pendenciasDefesa}" var="defesa" varStatus="c">
				              <tr>
				                <td align="center" bgcolor="#A7D7ED"><fmt:formatNumber value="${defesa.id}" minIntegerDigits="4" groupingUsed=""/></td>
				                <td align="center" bgcolor="#A7D7ED"><fmt:formatDate value="${defesa.data_defesa}" pattern="dd/MM/yyyy"/></td>
				                <td align="center" bgcolor="#A7D7ED">${defesa.orientador.nome}</td>
				                <td align="center" bgcolor="#A7D7ED">${defesa.aluno.nome}</td>
				                <td align="center" bgcolor="#A7D7ED">
					               	<!--<a href="" class="btn">Declaração</a>-->
							        <a href="admin/relatorios/propostas/ata-defesa-${defesa.id}" class="btn">Ata Defesa</a>
				                </td>
				              </tr>
				              </c:forEach>
				            </table>
				         </c:otherwise>
				      </c:choose>
				</div>
	         </div>

<div id="dialog" title="Mensagem do Sistema">
</div>
	
<div id="dialog-detalhes" title="Detalhes da Proposta #">
	<center><img src="static/imagens/ajax-loader.gif" id="loader"/></center>
	<div id="content">
	</div>
</div>

<%@ include file="../../includes/rodape.jsp" %>
</body>
</html>